<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <p>count的值是：{{count}}</p>
        <div><button v-on:click="addCount">+1</button></div>
        <div><button v-on:click="add(10)">add方法</button></div>
        <div><button @click="add(100)">简写的</button></div>
    </div>
    <script src="./lib/vue.js"></script>
    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                count: 0
            },
            methods: { // 事件处理函数
                // addCount: function() {
                //     console.log('绑定的事件');
                // }
                addCount() { // 简写
                    console.log('绑定的事件');
                    // vm.count += 1; // 不推荐
                    this.count += 1;
                },
                add(n) {
                    this.count += n;
                }
            }
        })
    </script>
</body>

</html>